#include <iostream>
#include <stdexcept>
#include <string>
#include <cmath>
#include <vector>

using namespace std::literals;

[[noreturn]] void panic(std::string s) {
    throw std::runtime_error(s); /* throw site */
}

double squareRoot(double x) {
    if (x < 0.0) {
        std::string s("square root of negative number"s);
        panic(s);
    }
    return std::sqrt(x);
}

int main() {
    std::vector<double> v{1.0, 4.0, -1.0};
    for (auto x : v) {
        try {
            std::cout << squareRoot(x) << "\n";
        }
        catch (std::runtime_error& e) {
            std::cout << "exception: " << e.what() << "\n";
        }
    }
}
